package com.guoxue.action.common;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSONObject;
import com.guoxue.util.LoggerUtil;

@Controller 
@RequestMapping("/common") 
public class FileUploadAction {
	
	  /** 上传目录名*/
	  @SuppressWarnings("unused")
	private static final String uploadFolderName = "uploadFiles";

	  /** 允许上传的扩展名*/
	  @SuppressWarnings("unused")
	private static final String [] extensionPermit = {"xlsx", "xls"};
	  
	  @SuppressWarnings("unused")
	  @ResponseBody 
	  @RequestMapping(value="/fileUpload",method = RequestMethod.POST)
	  public JSONObject fileUpload(@RequestParam("file") CommonsMultipartFile file,HttpSession session,
			   HttpServletRequest request, HttpServletResponse response) throws Exception{
		JSONObject json = new JSONObject();
	    try{
	    	String path = request.getSession().getServletContext().getRealPath("/");
	    }catch(Exception e){
	    	e.printStackTrace();
	    	LoggerUtil.logger.error("common_fileUpload"+e.getMessage(), e);
	    }
	    return json;
	  }
	
}
